﻿using Mobile.Controllers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting.Web;
using System.Web.Mvc;

namespace Mobile.Tests
{
    
    
    /// <summary>
    ///This is a test class for AdminUIControllerTest and is intended
    ///to contain all AdminUIControllerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class AdminUIControllerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for AdminUIController Constructor
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void AdminUIControllerConstructorTest()
        {
            AdminUIController target = new AdminUIController();
            //Ensure we are not constructing a null object
            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for AddSong
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void AddSongTest()
        {
            AdminUIController target = new AdminUIController(); // Initialize Controller
            string accessCode = "123"; //Initialized to our default party
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize to type we are expecting
            ActionResult actual;
            actual = target.AddSong(accessCode);

            //Unsure how to exactly define whole System.Web.Mvc.ViewResult, but want to at least check that output is correct type
            Type x = actual.GetType();
            Type y = expected.GetType();
            Assert.AreEqual(y, x, "Output is of expected type", null);

            //Make sure the result we return is not null
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for Index
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void IndexTest()
        {
            AdminUIController target = new AdminUIController(); // TODO: Initialize to an appropriate value
            ActionResult expected = new System.Web.Mvc.ViewResult(); // TODO: Initialize to an appropriate value
            ActionResult actual;
            actual = target.Index();
            //we want to make sure we are correctly returning of type 'View'
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);

            //Let's also assert we don't return a null view
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for Playlist
        ///</summary>
        // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
        // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
        // whether you are testing a page, web service, or a WCF service.
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void PlaylistTest()
        {
            AdminUIController target = new AdminUIController(); // Initialize controller
            FormCollection collection = new FormCollection(); // Playlist method takes parameter type of 'FormCollection
            collection.Add("partyCode", "123");
            //Set Expected value
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initializing to type we want to test
            ActionResult actual;
            actual = target.Playlist(collection);
            //Unsure how to exactly define whole System.Web.Mvc.ViewResult, but want to at least check that output is correct type
            Type x = actual.GetType();
            Type y = expected.GetType();
            Assert.AreEqual(y, x, "Output is of expected type", null);
            //Assert that the object returned is not null
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for SkipSong
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void SkipSongTest()
        {
            AdminUIController target = new AdminUIController(); // Initialize Controller
            ActionResult expected = new System.Web.Mvc.PartialViewResult(); // TODO: Initialize to an appropriate value
            ActionResult actual;
            string partyID = "123";
            actual = target.SkipSong(partyID);
            //we will be testing the output's type as it is hard to replicate the view object
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);

            //Check whether result is null
            Assert.IsNotNull(actual);
            
        }

        /// <summary>
        ///A test for UpvoteButton
        ///</summary>
        [TestMethod()]
        [UrlToTest("http://localhost:1034/")]
        [DeploymentItem("Mobile.dll")]
        public void UpvoteButtonTest()
        {
            AdminUIController_Accessor target = new AdminUIController_Accessor(); // initialize accessor
            string songID, PartyID;
            songID = null;
            PartyID = null;
            ActionResult expected = new System.Web.Mvc.PartialViewResult(); // Initialize to type we expect
            ActionResult actual;
            actual = target.UpvoteButton(songID, PartyID);
            //we will be testing the output's type as it is hard to replicate the view object
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);

            Assert.IsNotNull(actual);
            
        }
    }
}
